package com.graduation.vaccine.controller;


import com.graduation.vaccine.service.VaccinatedInfoService;
import com.graduation.vaccine.vo.AddFamilyVo;
import com.graduation.vaccine.vo.RespBean;
import com.graduation.vaccine.vo.UpdateVaccinatednVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZhaoJunYao
 * @since 2022-04-22
 */
@Controller
@RequestMapping("/vaccinated")
@Api(tags = "家人模块")
public class VaccinatedInfoController {

    @Autowired
    private VaccinatedInfoService vaccinatedInfoService;

    @ApiOperation("查询得到家人列表")
    @ResponseBody
    @PostMapping("/family")
    public RespBean getFamily(@RequestBody String phone){
        return vaccinatedInfoService.getFamily(phone);
    }

    @ApiOperation("添加家人")
    @ResponseBody
    @PostMapping("add/family")
    @Transactional(rollbackFor = Exception.class)
    public RespBean addFamily(@RequestBody AddFamilyVo addFamilyVo){
        return vaccinatedInfoService.addFamily(addFamilyVo);
    }

    @ApiOperation("修改接种人信息")
    @ResponseBody
    @PostMapping("update")
    public RespBean updateVaccinatedInfo(@RequestBody UpdateVaccinatednVo updateVaccinatednVo){
        return vaccinatedInfoService.updateVaccinatedInfo(updateVaccinatednVo);
    }

}
